package org.thss.petri.gef.ui;

import org.eclipse.emf.edit.ui.provider.AdapterFactoryContentProvider;
import org.eclipse.gef.EditPart;
import org.eclipse.ui.views.properties.IPropertySource;
import org.eclipse.ui.views.properties.IPropertySourceProvider;
import org.thss.petri.model.provider.PetriItemProviderAdapterFactory;

public class PetriNetPropertySourceProvider implements IPropertySourceProvider {
	IPropertySourceProvider modelPropertySourceProvider = new AdapterFactoryContentProvider(new PetriItemProviderAdapterFactory());
	
	@Override
	public IPropertySource getPropertySource(Object object) {
		IPropertySource source = null;
		if(object instanceof EditPart) {
			source = modelPropertySourceProvider.getPropertySource(((EditPart) object).getModel());
		} else {
			source = modelPropertySourceProvider.getPropertySource(object);
		}

		if(source != null) {
			return new UnwrappingPropertySource(source);
		} else {
			return null;
		}
	}

}
